/*
 * 
 * ControlComponent.java:
 * Handles drawing the robot controls
 */


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JToggleButton;


public class ControlPanel extends JPanel{
	
	RobotPanel robot;
	
	JButton addRobotToggle;
	JButton addBlockToggle;
	JButton drawLinesToggle;
	JButton clearDraw;
	JButton createPaths;

    //Toggles
	boolean add_robot;
	boolean add_block;
	
	ButtonListener bl;
	
	GridBagLayout gbl;
	GridBagConstraints gbconst;

	public ControlPanel(RobotPanel rob){
		
		this.robot = rob;
		
		//this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
		gbl = new GridBagLayout();
		gbconst = new GridBagConstraints();
		this.setLayout(gbl);
		this.setBorder(BorderFactory.createLineBorder(Color.black));
		this.setSize(new Dimension(180,500));
		this.setPreferredSize(new Dimension(180,500));
		this.setVisible(true);
		
		add_robot = false;
		add_block = false;
		
		createButtons();
	}
	
	public void createButtons(){
	    gbconst.fill = GridBagConstraints.HORIZONTAL;
	    gbconst.gridwidth = GridBagConstraints.REMAINDER;
	    gbconst.anchor = GridBagConstraints.NORTH;
	    //gbconst.weighty = 1;
	    
	    addRobotToggle = new JButton("Add Robot");
        addRobotToggle.setFont(new Font("sansserif",Font.PLAIN,20));
        gbl.setConstraints(addRobotToggle, gbconst);
        this.add(addRobotToggle);
        
        gbconst.weighty = 1;
        addBlockToggle = new JButton("Add Block");
        addBlockToggle.setFont(new Font("sansserif",Font.PLAIN,20));
        gbl.setConstraints(addBlockToggle, gbconst);
        this.add(addBlockToggle);
        
        bl = new ButtonListener(robot,this);
        gbconst.weighty = 0;
		
        drawLinesToggle = new JButton("Draw Lines");
        drawLinesToggle.setFont(new Font("sansserif",Font.PLAIN,20));
        gbl.setConstraints(drawLinesToggle, gbconst);
        this.add(drawLinesToggle);
        
        addRobotToggle.addActionListener(bl);
        addBlockToggle.addActionListener(bl);
        drawLinesToggle.addActionListener(bl);
        
        createPaths = new JButton("Create Paths");
        createPaths.addActionListener(bl);
        this.add(createPaths);
        
        clearDraw = new JButton("Clear");
        clearDraw.addActionListener(bl);
        this.add(clearDraw);
	}
}